<?php
    include_once '../../../../controlador/php/conexion/Conexion.php';
    $con = new Conexion();
    
    $fecha1 = $_REQUEST['capass2'];
    $fecha2 = $_REQUEST['capass22'];
    
    $f1 = date('Y-m-d',strtotime($fecha1));
    $f2 = date('Y-m-d',strtotime($fecha2));
    
    $indi = "select COUNT(*)as cantidad
            from atenMaterna inner join ".$con->getReal()."..ADNINGRESO on atenMaterna.adnIngreso=ADNINGRESO.OID
            inner join ".$con->getReal()."..GENPACIEN on atenMaterna.genPacien=GENPACIEN.OID
            where atenMaterna.ate_formTerEmb='cs' 
            and ate_fecha between '".$f1."' and '".$f2."'  
            and  (CAST(DATEDIFF(DD, GENPACIEN.GPAFECNAC, GETDATE()) / 365.25 AS INT)<18)
            union
            select count(hij_peso)
            from hijoMater inner join atenMaterna on hijoMater.ate_oid=atenMaterna.ate_oid
            where  ate_fecha between '".$f1."' and '".$f2."' and hij_peso < 2500";
    $lsti = $con->query($indi);
    while($res = mssql_fetch_array($lsti)){
        $lst[] = $res;
        //echo$res['cantidad'];
    }
    $con->cerrarConexion();
    print_r(json_encode($lst));

?>